
<template>
	<view class="headerbox">
		<image @click="toHome" src="" mode="heightFix"></image>
		<view class="" style="display: flex;width: 80%;">
			<view class="search" >
				<view class="inputs">
					<input type="text" placeholder="" v-model="searchContent"/>
					<i class="iconfont" @click="clear">&#xe785;</i>
				</view>
				<view class="line">
					
				</view>
				<el-dropdown @command="changeTag" style="width: 200rpx;">
				  <span class="el-dropdown-link">
				    {{tag == 1?'我的家庭':'我的生活'}} <i class="el-icon-arrow-down el-icon--right"></i>
				  </span>
				  <el-dropdown-menu slot="dropdown">
				    <el-dropdown-item command="1">我的家庭</el-dropdown-item>
				    <el-dropdown-item command="2">我的生活</el-dropdown-item>
				  </el-dropdown-menu>
				</el-dropdown>
				
			</view>
			<view class="searchicon" @click="search">
				<i class="iconfont">&#xe61d;</i>
			</view>
		</view>
		
		<view class="touxiang">
			<image :src="userInfo.avatar" mode="aspectFill"></image>
			{{userInfo.showName}}
		</view>
		
		<!-- <view class="tab">
			<span @click="toPage('/pages/tabbar/index/index')" :class="inv == 1?'active':''">首页</span>
			<span @click="toPage('/pages/tabbar/video/video')" :class="inv == 2?'active':''">视频</span>
			<span @click="toPage('/pages/chat/index')" :class="inv == 3?'active':''">AI管家</span>
			<span @click="toPage('/pages/tabbar/family/family')" :class="inv == 4?'active':''">家庭</span>
			<span @click="toPage('/pages/tabbar/mine/mine')" :class="inv == 5?'active':''">我的</span>
		</view>
		
		
		<view class="flexother">
			<view class="fabu" @click="releaseDia = true">
				<span>创作文章</span>
				<i class="iconfont">&#xe606;</i>
			</view>
			
			<view class="userimg"  @click="toPage('/pages/tabbar/mine/mine')" >
				<image :src="userInfo.avatar" mode=""></image>
			</view>
		</view>
		
		<u-popup :show="releaseDia" mode="center" round="20" @close="releaseDia = false">
			<release @closeDia="releaseDia = false" @toDraft="toDraft"></release>
		</u-popup> -->
	</view>
</template>

<script>
	import release from '@/components/release.vue';
export default {
	name: 'navTab',
	components: {
		release,
	},
	props: {
		inv:{
			default:1,
			type:Number
		}
	},
	data() {
		return {
			releaseDia:false,
			userInfo:{},
			searchContent:'',
			tag:1
		};
	},
	created() {
		var token = uni.getStorageSync('token') ? uni.getStorageSync('token') : ''
		if (token) {
			this.getuserInfo()
		}
	},
	methods: {
		changeTag(e){
			this.tag = e
		    this.search()
		},
		clear(){
			this.searchContent = ''
			this.search()
		},
		// 获取用户信息
		getuserInfo(){
			this.$api.myInfo().then(res => {
				console.log('用户信息')
				this.userInfo = res
			})
		},
		toHome(){
			uni.reLaunch({
				url:'/pages/tabbar/index/index'
			})
		},
		search(){
			let data = {
				tag:this.tag,
				searchContent:this.searchContent
			}
			this.$emit('search',data)
		},
		toPage(url){
			uni.navigateTo({
				url
			})
		}
	}
};
</script>

<style lang="scss">
.headerbox {
		width: 100%;
		height: 130rpx;
		background-color: #fff;
		position: sticky;
		top: 0;
		z-index: 10;
		box-shadow: 0 0 3px #cbcbcbcc;
		display: flex;
		align-items: center;
		padding: 0 15%;
		justify-content: space-between;
		
		.flexother{
			display: flex;
			align-items: center;
		}
		image {
			height: 80rpx;
			cursor: pointer;
			margin-right: 100px;
		}

		.tab {
			margin: 0 5%;

			span {
				margin-right: 80rpx;
				color: #929496;
				cursor: pointer;
				border-bottom: 2px solid #ffffff;
				padding-bottom: 40rpx;
				font-size: 30rpx;
			}

			span:hover {
				color: #de4849;
				border-color: #de4849;
			}
			
			.active{
				color: #de4849;
			}
		}
	}
	
	
	.userimg{
		width: 80rpx;
		height: 80rpx;
		border-radius: 50%;
		image{
			width: 100%;
			height: 100%;
			margin-left: 100rpx;
			border-radius: 50%;
		}
	}
	
	.touxiang{
		display: flex;
		align-items: center;
		white-space: nowrap;
		.iconfont {
			margin-right: 10px;
		}
		
		image {
			width: 25px;
			height: 25px;
			border-radius: 50%;
			margin-right: 10px;
		}
	}
	
	.search{
		background-color: #f6f4f4;
		width: 82%;
		height: 45px;
		border-radius: 5px;
		padding-left: 20px;
		display: flex;
		align-items: center;
		input{
			height: 100%;
			width: 100%;
		}
		
		.inputs{
			position: relative;
			display: flex;
			align-items: center;
			height: 100%;
			width: 84%;
			.iconfont{
				height: 100%;
				width: 50px;
				display: flex;
				align-items: center;
				justify-content: center;
				cursor: pointer;
			}
		}
		
		.line{
			height: 30px;
			width: 1px;
			background-color: #ccc;
			margin-right: 20px;
		}
		
		
	}
	
	.searchicon{
		width: 50px;
		height: 45px;
		display: flex;
		align-items: center;
		background-color: #f97f7f;
		justify-content: center;
		color: #fff;
		cursor: pointer;
		margin-left: 5px;
		
	}
	
	.fabu {
		display: flex;
		align-items: center;
		justify-content: center;
		margin-left: 100rpx;
		background-color: #de4849;
		padding: 20rpx 50rpx;
		border-radius: 10rpx;
		cursor: pointer;
		color:#fff;
		image {
			width: 50rpx;
			height: 50rpx;
		}
	
		span {
			font-size: 28rpx;
			color: #fff;
			margin-right: 20rpx;
		}
	}
	

</style>
